<?php
class Time_Policy_Model extends CI_Model {

	function __construct() {
		parent::__construct ();
		$this->load->database();
	}
	
	function add($data){
		return $this->db->insert ( 'timepolicy', $data );
	}

	function update($id,$data){
		$this->db->where('id',$id);
		$query = $this->db->get ( 'timepolicy' );
		
		if ($query->num_rows () == 0)
			return false;
		else {
			$this->db->where ( 'id', $id );
			if ($this->db->update ( 'timepolicy', $data ))
				return true;
			else
				return false;
		}
	}

	function delete($id){
		$this->db->where('id',$id);
		return $this->db->delete ( 'timepolicy' );
	}

	function get($id=0){
		if($id===0){
			$query = $this->db->get ( 'timepolicy' );
			return $query->result_array ();
		}
		else
		{
			$this->db->where('id',$id);
			$query = $this->db->get ( 'timepolicy' );
			return $query->row_array ();
		}
	}

}
?>